-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore template literals #14173
Ignore template literals #14173
Conversation
The line length limitation applied by linting is intended to improve readability. Unfortunately with template literals, practices used to get around it can inhibit readability. For example: return `The "${name}" array must have a length of ${ length}. Received length ${actual}`; Configure the linter to ignore line length limitations for template literals.
Improve readability of template literals by removing some creative use of line breaks.
I normally don't care about the linter stuff but this I'm -1 on. Having 80+ lines in annoying for those who don't have a wide screen. And having a single exception for this one case I find very odd. Surely the solution is to teach/enforce a better approach such as: const s = `The "${name}" array must have a length of \
${length}. Received length ${actual}`; or const s = `The "${name}" array must have a length of` +
` ${length}. Received length ${actual}`; |
FWIW, we already have exceptions for RegExps and URLs. |
@AndreasMadsen On the "annoying for those who don't have a wide screen" thing: Do you fall into that category? I've often suspected that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 Question
1 nit
@@ -267,8 +268,8 @@ function error_test() { | |||
expect: /\bSyntaxError: Invalid or unexpected token/ }, | |||
// do not fail when a String is created with line continuation | |||
{ client: client_unix, send: '\'the\\\nfourth\\\neye\'', | |||
expect: `${prompt_multiline}${prompt_multiline}'thefourtheye'\n${ | |||
prompt_unix}` }, | |||
expect: `${prompt_multiline}${prompt_multiline}'thefourtheye'\n` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why split in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting at \n
made sense elsewhere as it made the template literal layout approximate its output, although I can see that maybe it's not needed here.
@@ -253,6 +253,5 @@ for (const u in formatTests) { | |||
assert.strictEqual(actual, expect, | |||
`wonky format(${u}) == ${expect}\nactual:${actual}`); | |||
assert.strictEqual(actualObj, expect, | |||
`wonky format(${JSON.stringify(formatTests[u])}) == ${ | |||
expect}\nactual: ${actualObj}`); | |||
`wonky format(${JSON.stringify(formatTests[u])}) == ${expect}\nactual: ${actualObj}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one could be mitigated by chopping down all args.
Wrong button |
This is my normal setup: I'm sure there are ways I could get 10 chars extra but I don't think that is what we are talking about. I don't mind 80+ lines when it is clear that no better alternative exists (such as URLs). However, in this case, I strongly believe better alternatives exist. |
@AndreasMadsen could you please repost that in #14176. Personally I'd take 10 more chars 😺 |
I'm also -1 on this. As @AndreasMadsen said better alternatives exist. |
Also -1 |
As much as I get annoyed by the 80 char limit, I'm in favor of keeping it. -1 on this. |
Thanks, everyone! I'm going to close this as (obviously) there is not consensus and I don't intend to argue strenuously for this. I'll instead try to refactor more egregious formatting of template literals into things I find more readable and sensible. New indentation linting may force that anyway. |
First commit:
Second commit:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
tools test lib